package 特殊文件;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;

public class main {
    public static void main(String[] args) throws IOException,Exception {

        Properties properties = new Properties();

        System.out.println(properties);



        properties.load(new FileReader("C:\\git_java\\特殊文件\\user.Properties"));

        System.out.println(properties);

        //遍历全部的键和值
        Set<String> keys = properties.stringPropertyNames();

        for (String key : keys) {
            String value = properties.getProperty(key);
            System.out.println(key+"........"+value);
        }

        properties.forEach((k,v)-> {
            System.out.println(k+"......"+v);
        });

        properties.setProperty("张无忌","mainmian");

//        2、把对象中的文件属性写入到文件中

        properties.store(new FileWriter("C:\\git_java\\特殊文件\\user2.Properties"),"保存很多用户");






    }

}
